﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace KhachSan.Process.Private.Bo
{
    public partial class FlatButton : UserControl
    {
        public FlatButton()
        {
            InitializeComponent();
            this.BackColor = Color.FromArgb(Mau);

        }
        public delegate void Flat_Click(Object flatButton);
        public  Flat_Click flat_Click;
        private int mau=-4599318;

        public int Mau
        {
            get { return mau; }
            set {
                this.BackColor = Color.FromArgb(mau);
                mau = value;
            
            }
        }
        public LabelControl Text
        {
            get { return this.lbText; }
            set { lbText = value; }
        }

        private void lbText_Click(object sender, EventArgs e)
        {
            flat_Click(this);
        }

        private void FlatButton_Click(object sender, EventArgs e)
        {
            flat_Click(this);
        }

        private void FlatButton_MouseHover(object sender, EventArgs e)
        {
            this.BackColor =Color.FromArgb( Mau+5000);
        }

        private void FlatButton_MouseLeave(object sender, EventArgs e)
        {
            this.BackColor = Color.FromArgb(Mau);
        }

        private void FlatButton_Resize(object sender, EventArgs e)
        {
            lbText.Location = new Point(0, (this.Height / 2)-(lbText.Height/2));
        }

        private void lbText_MouseHover(object sender, EventArgs e)
        {
            this.BackColor = Color.FromArgb(Mau+5000);
        }

        private void lbText_MouseLeave(object sender, EventArgs e)
        {
            Point c = System.Windows.Forms.Cursor.Position;
            Point p = this.PointToClient(c);

            if (p.X > this.Location.X || p.Y > this.Location.Y || p.X < this.Location.X || p.Y < this.Location.Y)
                this.BackColor = Color.FromArgb(Mau);
        }
    }
}
